package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.Book;
import com.example.mapper.BookMapper;
import com.example.service.IBookService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 代码练习僧
 * @since 2025-04-02
 */
@Service // service层和mapper层的关联，mybatis-plus已经实现
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements IBookService {

    @Override
    public Object getBookByAuthor(String author) {
        // 构造条件，使用bookMapper去调API进行查询
        return baseMapper.getBookByAuthor(author);
    }

    @Override
    public Object getBooksByName(String bookName) {
        QueryWrapper<Book> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("book_name", bookName);
        return baseMapper.selectList(queryWrapper);
    }
}
